package com.dl.mall;

import com.dl.mall.entity.ProductSpecs;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;


/**
 * @author DL
 * @create 2022-05-13 15:11
 */
@SpringBootTest
class testCanal {


    @Test
    void contextLoads() {
        //声明一个List集合
        List<ProductSpecs> list = new ArrayList<>();
        list.add(new ProductSpecs().setSpecsId("1001").setSpecsStock(1));
        list.add(new ProductSpecs().setSpecsId("1002").setSpecsStock(2));
        list.add(new ProductSpecs().setSpecsId("1003").setSpecsStock(3));
        list.add(new ProductSpecs().setSpecsId("1004").setSpecsStock(4));

        Map<String, Integer> map =
                list.stream().collect(Collectors.toMap(
                        ProductSpecs::getSpecsId,
                        ProductSpecs::getSpecsStock
                ));
        System.out.println("map = " + map);
    }


    @Test
    void contextLoads2() {
  /*      String fileName = "130181";
        String format = String.format("%025d", Integer.valueOf(fileName));
        long l = Long.parseLong("1" + format);
        System.out.println("l = " + l);*/


        ThreadLocalRandom random = ThreadLocalRandom.current();
        Integer randomInt = random.nextInt(10000);
        System.out.println("randomInt = " + randomInt);
        String format2 = String.format("%05d", randomInt);
        System.out.println("format2 = " + format2);

        String yyyyMMddHHmmssSSS = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
        String a = yyyyMMddHHmmssSSS + format2;
        System.out.println("a = " + a.trim());


    }


}
